﻿namespace WMS6.Web.Inventory
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class InvLotLocLpnQuery : BasePage
    {
        protected Button btnList;
        protected Button btnSearch;
        protected CheckBox cbxHistory;
        protected DropDownList ddlExternalLotOper;
        protected DropDownList ddlLoc;
        protected DropDownList ddlLot;
        protected DropDownList ddlLpnOper;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlSkuDescrOper;
        protected DropDownList ddlSkuID;
        protected DropDownList ddlVendorIDOper;
        protected HtmlForm form1;
        protected HtmlInputHidden hdnActionID;
        protected HtmlHead Head1;
        protected Label lblExternalLot;
        protected Label lblLoc;
        protected Label lblLot;
        protected Label lblLpn;
        protected Label lblOwnerID;
        protected Label lblReceiptQuery;
        protected Label lblSkuDescr;
        protected Label lblSkuID;
        protected Label lblVendorID;
        protected HtmlLink mycss;
        protected TextBox txtExternalLot;
        protected TextBox txtLoc;
        protected TextBox txtLot;
        protected TextBox txtLpn;
        protected TextBox txtOwnerID;
        protected TextBox txtSkuDescr;
        protected TextBox txtSkuID;
        protected TextBox txtVendorID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InvLotLocLpnList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InvLotLocLpnList.aspx?action={0}&ownerID={1}", base.UrlEncode(this.hdnActionID.Value.Trim()), base.UrlEncode(this.txtOwnerID.Text)), false);
        }

        private void LoadDDl()
        {
            this.txtOwnerID.Text = base.Request.QueryString["OwnerID"];
            base.InitQueryDDL(this.ddlLoc, 0);
            base.InitQueryDDL(this.ddlLot, 0);
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlSkuID, 0);
            base.InitQueryDDL(this.ddlLpnOper, 0);
            base.InitQueryDDL(this.ddlSkuDescrOper, 0);
            base.InitQueryDDL(this.ddlExternalLotOper, 0);
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.InitPage(this.Page);
            this.LoadDDl();
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                this.txtOwnerID.Text = base.Request.QueryString["OwnerID"];
                this.txtSkuID.Text = base.Request.QueryString["SkuID"];
                this.cbxHistory.Checked = base.Request.QueryString["History"] == "Y";
                this.hdnActionID.Value = base.Request.QueryString["action"];
                base.Server.Transfer(string.Format("InvLotLocLpnList.aspx?action={0}&ownerID={1}&NewSearch=false", base.UrlEncode(this.hdnActionID.Value.Trim()), base.UrlEncode(this.txtOwnerID.Text)), false);
            }
        }

        public string ExternalLot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternalLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternalLot.Text.Trim(), this.ddlExternalLotOper.SelectedValue);
                }
                return "";
            }
        }

        public string History
        {
            get
            {
                if (this.cbxHistory.Checked)
                {
                    return "Y";
                }
                return "N";
            }
        }

        public string Loc
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLoc.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLoc.Text.Trim(), this.ddlLoc.SelectedValue);
                }
                return "";
            }
        }

        public string Lot
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLot.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLot.Text.Trim(), this.ddlLot.SelectedValue);
                }
                return "";
            }
        }

        public string Lpn
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLpn.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLpn.Text.Trim(), this.ddlLpnOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string SkuDescr
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuDescr.Text.Trim(), this.ddlSkuDescrOper.SelectedValue);
                }
                return "";
            }
        }

        public string SkuID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuID.Text.Trim(), this.ddlSkuID.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text.Trim(), this.ddlVendorIDOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

